package com.example.jwts.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    /**
     * 自定义拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyHandler())
                //拦截全部
                .addPathPatterns("/**")
                //不需拦截的请求
                .excludePathPatterns(this.exclud());
    }
    /**
     *     不需拦截的请求
     */
    public String[] exclud(){
        String[] urls= {
                "/login"
        };
        return urls;
    }
}
